<template>
    <div class="lotsReleaseAdd">
        <div class="getBack_SAVE">
            <div class="l_getBack">
               <div class="l_back_box">
                    <el-button type="text" @click="goback"><i class="el-icon-back"></i>返回</el-button>
                </div> 
                <el-divider direction="vertical"></el-divider>
                <div class="l_back_tit">{{title_page}}</div>
            </div>
            <div>
                <el-button plain size="mini" @click="saveSmallData">保存</el-button>
                <!-- 隐藏保存并发布按钮 -->
                <el-button v-if="false" type="primary" size="mini" @click="saveBigUploadData">保存并发布</el-button>
            </div>
        </div>
        <div class="all_box">
            <div class="disposalUniInfor">
                <div class="title_firm">处置单位信息</div>
                <el-form :inline="true" ref="firmForm" :model="firmForm" :rules="firmRules" class="demo-form-inline" label-width="100px">
                    <el-form-item label="处置单位:">
                        <el-input v-model="firmForm.dispose_unit" placeholder="处置单位" size="mini" :disabled="true"></el-input>
                    </el-form-item>
                    <el-form-item label="联系人:" prop="contacts">
                        <el-input v-model="firmForm.contacts" placeholder="联系人" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="联系电话:" prop="phone">
                        <el-input v-model="firmForm.phone" placeholder="联系电话" size="mini"></el-input>
                    </el-form-item>
                    <el-form-item label="处置地点:" prop="area" class="lineOne">
                        <el-cascader
                        v-model="province1"
                        :options="provinceOptions"
                        @change="provinceChange"
                        size="mini">
                    </el-cascader>
                    </el-form-item>
                    <el-form-item label="详细地址:" prop="address">
                        <el-input v-model="firmForm.address" size="mini" placeholder="详细地址" style="width: 250px;"></el-input>
                    </el-form-item>
                    <div class="title_firm">处置物资信息</div>
                    <el-form-item label="拍卖会名称:" prop="name">
                        <el-input v-model="firmForm.name" size="mini" placeholder="拍卖会名称" style="width: 250px;"></el-input>
                    </el-form-item>
                </el-form>  

                
                
            </div>

            <div class="lots_Table">
                <div class="title_LT">
                    <div class="title_firm">标的物信息</div>
                    <div>
                        <el-button type="primary" size="mini" @click="addLotsItem">新增</el-button>
                        <el-divider direction="vertical"></el-divider>
                        <i class="el-icon-setting" style="color: #409EFF;"></i>
                    </div>
                </div>
                <el-table
                    :data="lotsTable"
                    :border="true"
                    height="180"
                    :header-cell-style="{background:'#f5f7fa'}">
                    <el-table-column type="index" label="#" align="center">
                    </el-table-column>
                    <el-table-column label="标的类型" prop="type_label" align="center">
                    </el-table-column>
                    <el-table-column label="标的名称" prop="name" align="center">
                    </el-table-column>
                    <el-table-column label="单位" prop="unit" align="center">
                    </el-table-column>
                    <el-table-column label="预估数量" prop="amount" align="center">
                    </el-table-column>
                    <el-table-column label="保留单价(元)" prop="min_price" align="center">
                    </el-table-column>
                    <el-table-column label="起始单价(元)" prop="start_price" align="center">
                    </el-table-column>
                    <el-table-column label="是否含税" prop="taxnum" align="center">
                    </el-table-column>
                    <el-table-column label="操作" align="center" width="100">
                        <!-- <template slot-scope="scope">
                            <el-button class="table_btn" type="text" @click="editOperate(scope.row)">编辑</el-button>
                            <el-button class="table_btn" type="text" @click="deleteOperate(scope.row)">删除</el-button>
                        </template> -->
                    </el-table-column>
                </el-table>
            </div>
            <div class="word_content">
                <div class="l_box">
                    <div class="l_dispose">
                        <div class="title_firm">处置计划</div>
                        <el-form :inline="true" ref="planForms" :model="planForms" :rules="planRules" class="demo-form-inline" label-width="90px">
                            <el-form-item label="拟拍日期:" prop="protocols_time">
                                <el-date-picker
                                v-model="planForms.protocols_time"
                                type="datetime"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                placeholder="选择拟拍日期"
                                size="mini"
                                style="width: 180px;" />
                            </el-form-item>
                            <el-form-item label="处置方式:" prop="dispose_way">
                                <el-select v-model="planForms.dispose_way" size="mini" placeholder="请选择" style="width: 150px;">
                                    <el-option
                                    v-for="item in dispose_wayOptions"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                    size="mini">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="委托方式:" prop="delegationMode">
                                <el-select v-model="delegationMode" size="mini" placeholder="请选择" style="width: 150px;">
                                    <el-option
                                    v-for="item in delegationModeOptions"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                    size="mini">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                            <el-form-item label="服务单位:" class="firmTable_s">
                                <el-table
                                    :data="serveData"
                                    border
                                    style="width: 100%"
                                    :header-cell-style="{background:'#f5f7fa'}">
                                    <el-table-column
                                    prop="serveFirm"
                                    label="服务单位" 
                                    width="280">
                                    </el-table-column>
                                    <el-table-column
                                    prop="contacts"
                                    label="联系人">
                                    </el-table-column>
                                    <el-table-column
                                    prop="phone"
                                    label="联系电话"
                                    width="110">
                                    </el-table-column>
                                </el-table>
                            </el-form-item>
                        </el-form>
                    </div>
                    <div class="l_approve">
                        <div class="title_firm">审批要求</div>
                        <el-form ref="approveForm" :model="approveForm" class="demo-form-inline" label-width="100px">
                            <el-row>
                                <el-col :span="12">
                                    <el-form-item label="拍前审批:">
                                        <el-radio-group v-model="approveForm.preposition_check" @input="pre_checkChange">
                                            <el-radio :label="'0'">未审批</el-radio>
                                            <el-radio :label="'1'">已审批</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <div class="fs_color_tips colorRed m_top">1、先拍后审:选择“未审批”，则拍后审批自动选择“需要”。</div>
                                    <div class="fs_color_tips colorRed">2、先审后拍:选择“已审批”，请上传“内部审批单”。</div>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="12">
                                    <el-form-item label="内部审批单:" prop="preposition_check_file" :rules="[{required:isRequired,message:'请上传内部审批单',trigger:'blur'}]">
                                        <el-upload class="upload-demo" :action="imgurls + '/entrust/Common/file'" :on-success="fileSuccess"
                                        :file-list="fileList" :limit="1" :on-remove="examineRemove">
                                        <el-button size="small" type="primary">点击上传</el-button>
                                        <div slot="tip" class="el-upload__tip">文件大小不超过10MB</div>
                                        </el-upload>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="12">
                                    <el-form-item label="拍后审批:">
                                        <el-radio-group v-model="approveForm.postposition_check" :disabled="postCheckDis">
                                            <el-radio :label="'0'">不需要</el-radio>
                                            <el-radio :label="'1'">需要</el-radio>
                                        </el-radio-group>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="12">
                                    <div class="fs_color_tips colorRed m_top">1、根据企业管理规定是否需要审批后才能成交。</div>
                                    <div class="fs_color_tips colorRed">1、最高价超保留价是否需要审批才能成交。</div>
                                </el-col>
                            </el-row>
                            
                        </el-form>
                    </div>
                </div>
                <div class="r_box">
                    <div class="one_editor">
                        <div class="title_firm title_rbox">资质要求</div>
                        <!-- <quill-editor ref="myTextEditor" v-model="firmForm.certification_require"
                            :options="editorOption1"  @blur="ChangeFn('certification_require')">
                        </quill-editor> -->
                        <tinymce v-model="firmForm.certification_require"></tinymce>
                    </div>
                    <div class="two_editor">
                        <div class="title_firm title_rbox">其他要求</div>
                        <!-- <quill-editor ref="myTextEditor" v-model="firmForm.else_require"
                            :options="editorOption2"  @blur="ChangeFn('else_require')">
                        </quill-editor> -->
                        <tinymce v-model="firmForm.else_require"></tinymce>
                    </div>
                    
                </div>
            </div>
        </div>
        
        <dialogLotsAdd 
        :title="title_d" 
        :showLotsAdd="showLotsAdd"
        @cancelDiaAdd="cancelDiaAdd"
        @showListLots="showListLots" />
    </div>
</template>

<script>
import dialogLotsAdd from './dialogLotsAdd.vue'
import {areaTree} from '@/api/user'
import {examineEntrustAuction,AuctionAdd,AuctionEdit,lotsType} from '@/api/release'
import tinymce from '@/components/Tinymce.vue';
import { mapState } from 'vuex'
import {intervalTime,dateOrTime} from '@/utils/index'
export default {
    name: 'lotsReleaseAdd',
    components: {
        dialogLotsAdd,tinymce
    },
    data(){
        return{
            editorOption1:{
                modules: {
                    toolbar: [
                        ["bold", "italic", "underline", "strike"], // 加粗 斜体 下划线 删除线
                        // ["blockquote", "code-block"], // 引用  代码块
                        [{
                        header: 1
                        }, {
                        header: 2
                        }], // 1、2 级标题
                        [{
                        list: "ordered"
                        }, {
                        list: "bullet"
                        }], // 有序、无序列表
                        [{
                        script: "sub"
                        }, {
                        script: "super"
                        }], // 上标/下标
                        [{
                        indent: "-1"
                        }, {
                        indent: "+1"
                        }], // 缩进
                        // [{'direction': 'rtl'}],                         // 文本方向
                        [{
                        size: ["small", false, "large", "huge"]
                        }], // 字体大小
                        [{
                        header: [1, 2, 3, 4, 5, 6, false]
                        }], // 标题
                        [{
                        color: []
                        }, {
                        background: []
                        }], // 字体颜色、字体背景颜色
                        [{
                        font: []
                        }], // 字体种类
                        [{
                        align: []
                        }], // 对齐方式
                        ["clean"], // 清除文本格式
                    ], //工具菜单栏配置
                },
                placeholder: "请输入资质要求需要特别说明的事项", //提示
                readyOnly: false, //是否只读
                theme: "snow", //主题 snow/bubble
                syntax: true, //语法检测
            },
            editorOption2:{
                modules: {
                    toolbar: [
                        ["bold", "italic", "underline", "strike"], // 加粗 斜体 下划线 删除线
                        // ["blockquote", "code-block"], // 引用  代码块
                        [{
                        header: 1
                        }, {
                        header: 2
                        }], // 1、2 级标题
                        [{
                        list: "ordered"
                        }, {
                        list: "bullet"
                        }], // 有序、无序列表
                        [{
                        script: "sub"
                        }, {
                        script: "super"
                        }], // 上标/下标
                        [{
                        indent: "-1"
                        }, {
                        indent: "+1"
                        }], // 缩进
                        // [{'direction': 'rtl'}],                         // 文本方向
                        [{
                        size: ["small", false, "large", "huge"]
                        }], // 字体大小
                        [{
                        header: [1, 2, 3, 4, 5, 6, false]
                        }], // 标题
                        [{
                        color: []
                        }, {
                        background: []
                        }], // 字体颜色、字体背景颜色
                        [{
                        font: []
                        }], // 字体种类
                        [{
                        align: []
                        }], // 对齐方式
                        ["clean"], // 清除文本格式
                    ], //工具菜单栏配置
                },
                placeholder: "请输人其他要求，包括拉货时间，看货事项等", //提示
                readyOnly: false, //是否只读
                theme: "snow", //主题 snow/bubble
                syntax: true, //语法检测
            },
            /**********title***************/ 
            title_page:'',
            /********处置单位信息***********/ 
            firmForm:{
                dispose_unit: '',
                contacts:'',
                phone:'',
                address:'',
                province:'',
                city:'',
                area:'',
                name:'', //拍卖会名称
                certification_require:"", //资质要求
                else_require:"", //其他要求
            },
            firmRules:{
                contacts:[{ required: true, trigger: 'blur',message:'请输入联系人'}],
                phone:[{ required: true, trigger: 'blur',message:'请输入联系电话'}],
                address:[{ required: true, trigger: 'change',message:'请选择处置地点'}],
                area:[{ required: true, trigger: 'blur',message:'请输入详细地址'}],
                name:[{ required: true, trigger: 'blur',message:'请输入拍卖会名称'}],
            },
            province1:'', //处置地点值
            provinceOptions:[], //处置地点数据

            /***处置计划***********/ 
            dispose_wayOptions:[
                {
                value: '1',
                label: '一次性处置'
                },
                {
                value: '2',
                label: '拉货权处置'
                },
            ], //处置方式下拉数据
            delegationModeOptions:[{
                value: '1',
                label: '独家委托'
            }],
            delegationMode:'1', //独家委托
            serveData:[{serveFirm:'河北一盟拍卖有限公司',contacts:"李恒东",phone:"18731185621"}], //服务单位列表数据
            planForms:{
                protocols_time:null,
                dispose_way:'1',
                service_id:'1',
            },
            planRules:{
                protocols_time:[{ required: true, message: '拟拍日期不能为空', trigger: 'change' }],
                dispose_way:[{ required: true, message: '处置方式不能为空', trigger: 'change' }], //处置方式
                service_id:[{ required: true, message: '服务单位不能为空', trigger: 'change' }],
            },

            /***审批要求*************/ 
            approveForm:{
                preposition_check:'1', //拍前审批0不需要1需要
                postposition_check:'1', //拍卖后审批 0不需要1需要 当拍前审批为0不需要时 拍后审批必须为1需要
                preposition_check_file:'', //文件
                lots_ids:'',
            },
            isRequired:true,
            postCheckDis:false, //拍后审批是否禁用
            authorizationFiles:[],
            fileList:[],

            /*****标的物信息*******/
            lotsTable:[], //标的物信息表格数据
            // 标的新增弹窗
            title_d:'',
            showLotsAdd:false,
        }
    },
    computed:{
        ...mapState('user',['token','userInfo','lotsAry'])
    },
    created(){
        let query = this.$route.query;
        // 增加默认值处理逻辑
        if (query.title === "add") {
            this.title_page = '新增';
        } else if (query.title === "edit") {
            this.title_page = '编辑';
            this.getAuctionLotsData();
            
        } else {
            console.warn('路由参数 title 缺失或无效，默认设置为新增');
            this.title_page = '新增'; // 默认值为新增
        }
        this.firmForm.dispose_unit = this.userInfo.company_name; //处置单位名称
        this.firmForm.contacts = this.userInfo.username; //处置单位联系人
        this.firmForm.phone = this.userInfo.mobile; //处置单位手机号
        this.list();
        this.$store.commit('user/CLEARL_LOTS', []);
        // 修改：使用本地时间格式化，默认时间正确显示为本地时间
        const now = new Date();
        this.planForms.protocols_time = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(now.getDate()).padStart(2, '0')} ${String(now.getHours()).padStart(2, '0')}:${String(now.getMinutes()).padStart(2, '0')}:${String(now.getSeconds()).padStart(2, '0')}`;
    },
    methods:{
       goback(){
            this.$router.push('/sellerRelease')
        },
        list(){
            // lotsList().then(res => {
            //     this.lotsTable=res.data;
            // });
            areaTree().then(res =>{
                var arr = this.areatreeAfter(res.data);
                this.provinceOptions = arr;
            });
        },
        //修改
        getAuctionLotsData() {
            let id = this.$route.query.id;
            examineEntrustAuction({ auction_id: id }).then(res => {
                let aucData = res.data.auctionData;
                this.lotsTable = res.data.lotsData.map(item => ({
                    ...item,
                    type_label: item.type_label || '未知类型', // 确保 type_label 字段存在
                }));
                this.firmForm.dispose_unit = aucData.dispose_unit;
                this.firmForm.contacts = aucData.contacts;
                this.firmForm.phone = aucData.phone;
                this.firmForm.address = aucData.address;
                this.firmForm.province = aucData.province;
                this.firmForm.city = aucData.city;
                this.firmForm.area = aucData.area;
                this.firmForm.name = aucData.name; // 拍卖会名称
                this.firmForm.certification_require = aucData.certification_require; // 资质要求
                this.firmForm.else_require = aucData.else_require; // 其他要求
                this.province1 = [aucData.province, aucData.city, aucData.area];

                this.planForms.protocols_time = intervalTime(aucData.protocols_time);
                this.planForms.dispose_way = aucData.dispose_way;
                this.planForms.service_id = aucData.service_id;

                this.approveForm.preposition_check = aucData.preposition_check;
                this.approveForm.postposition_check = aucData.postposition_check;
                // console.log(this.approveForm.preposition_check,'this.approveForm.preposition_check');
                if(this.approveForm.preposition_check == '0'){
                    this.isRequired = false;
                }
                // this.approveForm.postposition_check = aucData.postposition_check;
                if(aucData.preposition_check_file){
                 this.approveForm.preposition_check_file = aucData.preposition_check_file;    
                }
                // 文件
                // this.authorizationFiles[0] = aucData.preposition_check_file;
                // console.log(aucData.preposition_check_file,'aucData.preposition_check_file');
                this.authorizationFiles = aucData.preposition_check_file;
                this.approveForm.lots_ids = aucData.lots_ids;
                this.fileList = aucData.preposition_check_file.map(item => ({
                    name: item.file_name,
                    url: this.imgurls + item.file_path
                }));
            });
        },
        provinceChange(){
            this.$set(this.firmForm,'province',this.province1[0]);
            this.$set(this.firmForm,'city',this.province1[1]);
            this.$set(this.firmForm,'area',this.province1[2]);
        },
        //处置点数据调整
        areatreeAfter(data){
            for(var i=0;i < data.length; i++){
                var obj={
                    value:data[i].id,
                    label:data[i].name,
                    children:data[i].children,
                }
                
                data[i]=obj;
                if(data[i].children){
                this.areatreeAfter(data[i].children);
                }
            }
            return data;
        },
        
        /***标的新增列表*********/ 
        addLotsItem(){
            this.title_d = '新增';
            this.showLotsAdd = true;
        },
        cancelDiaAdd(){
            this.showLotsAdd = false;
        },
        showListLots(){
            this.lotsTable=this.lotsAry;
        },
        /***审批要求***********/
        pre_checkChange(label){
            
            if(label=='1'){
                this.postCheckDis = false;
                this.isRequired = true;
            }else{
                this.postCheckDis = true;
                this.isRequired = false;
                this.approveForm.postposition_check = '1';
            }
        },
        //内部审批单上传
        fileSuccess(res, file) {
            this.$message({
            message: res.msg,
            type: "success",
            });
            this.authorizationFiles.push(res.data.id)
        },
        ChangeFn(text){
            this.$refs['firmForm'].validateField(text);
        },
        /********/
        //点击保存
        saveSmallData() {
            this.setformValue();
            Promise.all([
                this.$refs.firmForm.validate().then(v => v, e => e),
                this.$refs.planForms.validate().then(v => v, e => e),
                this.$refs.approveForm.validate().then(v => v, e => e)
            ]).then(([v1, v2, v3]) => {
                if (v1 && v2 && v3) {
                    if (this.lotsTable.length > 0) {
                        let arr = JSON.stringify(this.lotsTable);
                        // 构造提交用的 planForms 副本
                        let submitPlanForms = {
                            ...this.planForms,
                            protocols_time: this.time(this.planForms.protocols_time)
                        };
                        let obj = { ...this.firmForm, ...submitPlanForms, ...this.approveForm, company_id: this.userInfo.company_id, lots_datas: arr };
                        // 判断 title 参数
                        const title = this.$route.query.title;
                        if (title === 'add') {
                            AuctionAdd(obj)
                                .then(res => {
                                    this.$message({
                                        message: res.msg,
                                        type: "success",
                                    });
                                    this.$store.commit('user/CLEARL_LOTS', []);
                                    this.$refs.firmForm.resetFields();
                                    this.$refs.planForms.resetFields();
                                    this.planForms.dispose_way = '1';
                                    this.planForms.service_id = '1';
                                    this.$refs.approveForm.resetFields();
                                    this.$router.push('/sellerRelease');
                                })
                                .catch(err => {
                                    console.error('AuctionAdd error:', err);
                                    this.$message({
                                        message: '保存失败，请稍后重试',
                                        type: "error",
                                    });
                                });
                        } else if (title === 'edit') {
                            console.log(AuctionEdit);
                            console.log(obj);
                            const editObj = { ...obj, id: this.$route.query.id };
                            AuctionEdit(editObj)
                                .then(res => {
                                    this.$message({
                                        message: res.msg,
                                        type: "success",
                                    });
                                    console.log('编辑');
                                    this.$store.commit('user/CLEARL_LOTS', []);
                                    this.$refs.firmForm.resetFields();
                                    this.$refs.planForms.resetFields();
                                    this.planForms.dispose_way = '1';
                                    this.planForms.service_id = '1';
                                    this.$refs.approveForm.resetFields();
                                    this.$router.push('/sellerRelease');
                                })
                                .catch(err => {
                                    console.error('AuctionEdit error:', err);
                                    this.$message({
                                        message: '保存失败，请稍后重试',
                                        type: "error",
                                    });
                                });
                        } else {
                            console.warn('Invalid title parameter:', title);
                            this.$message({
                                message: '无效的标题参数',
                                type: "error",
                            });
                        }
                    } else {
                        this.$message({
                            message: '请新增标的物信息',
                            type: "error",
                        });
                    }
                } else {
                    this.$message({
                        message: '表单验证失败，请检查输入',
                        type: "error",
                    });
                }
            }).catch(err => {
                console.error('Validation failed:', err);
                this.$message({
                    message: '表单验证失败，请检查输入',
                    type: "error",
                });
            });
        },

        saveBigUploadData() {
            this.setformValue();
            Promise.all([
                this.$refs.firmForm.validate().then(v => v, e => e),
                this.$refs.planForms.validate().then(v => v, e => e),
                this.$refs.approveForm.validate().then(v => v, e => e)
            ]).then(([v1, v2, v3]) => {
                if (v1 && v2 && v3) {
                    if (this.lotsTable.length > 0) {
                        let arr = JSON.stringify(this.lotsTable);
                        let concatobj = {
                            company_id: this.userInfo.company_id,
                            lots_datas: arr,
                            type: '1'
                        };
                        if(this.planForms.protocols_time){
                                this.planForms.protocols_time = this.time(this.planForms.protocols_time);
                        }
                        let obj = { ...this.firmForm, ...this.planForms, ...this.approveForm, ...concatobj };
                        // 判断 title 参数
                        const title = this.$route.query.title;
                        if (title === 'add') {
                             
                            AuctionAdd(obj)
                                .then(res => {
                                    this.$message({
                                        message: res.msg,
                                        type: "success",
                                    });
                                    this.$store.commit('user/CLEARL_LOTS', []);
                                    this.$refs.firmForm.resetFields();
                                    this.$refs.planForms.resetFields();
                                    this.$refs.approveForm.resetFields();
                                    this.$router.push('/sellerRelease');
                                })
                                .catch(err => {
                                    console.error('AuctionAdd error:', err);
                                    this.$message({
                                        message: '保存失败，请稍后重试',
                                        type: "error",
                                    });
                                });
                        } else if (title === 'edit') {
                            AuctionEdit(obj)
                                .then(res => {
                                    this.$message({
                                        message: res.msg,
                                        type: "success",
                                    });
                                    this.$store.commit('user/CLEARL_LOTS', []);
                                    this.$refs.firmForm.resetFields();
                                    this.$refs.planForms.resetFields();
                                    this.$refs.approveForm.resetFields();
                                    this.$router.push('/sellerRelease');
                                })
                                .catch(err => {
                                    console.error('AuctionEdit error:', err);
                                    this.$message({
                                        message: '保存失败，请稍后重试',
                                        type: "error",
                                    });
                                });
                        } else {
                            console.warn('Invalid title parameter:', title);
                            this.$message({
                                message: '无效的标题参数',
                                type: "error",
                            });
                        }
                    } else {
                        this.$message({
                            message: '请新增标的物信息',
                            type: "error",
                        });
                    }
                } else {
                    this.$message({
                        message: '表单验证失败，请检查输入',
                        type: "error",
                    });
                }
            }).catch(err => {
                console.error('Validation failed:', err);
                this.$message({
                    message: '表单验证失败，请检查输入',
                    type: "error",
                });
            });
        },
        setformValue(){
            let arr =this.authorizationFiles.join(',');
            console.log(this.authorizationFiles.join(','),'authorizationFiles');
            // let arr =this.authorizationFiles;
            this.approveForm.preposition_check_file = arr;
            var lotsWords =[];
            this.lotsTable.forEach(item =>{
                lotsWords.push(item.id);
            });
            this.approveForm.lots_ids= lotsWords.join(',');
           
        },
        
        time(time){
            // 增加对输入参数类型的校验
            if (typeof time !== 'string') {
                console.error('Invalid time format:', time);
                return '';
            }
            var date = new Date(time.replace(/-/g, '/'));
            var t = Date.parse(date) / 1000; // 修改：将毫秒级时间戳转换为秒级时间戳
            return t;
        },
        downloadPic(urlVal){
            const url = this.imgurls+urlVal;
            window.open(url);
        },
        examineRemove(file, fileList){
            this.fileList = fileList;
            var arr=[];
            fileList.forEach(item => {
                arr.push(item.response.data.id);
            });
            this.authorizationFiles = arr;
        },
        editOperate(row) {
            this.title_d = '修改';
            this.$store.commit('user/SET_LOTS', row);
            this.showLotsAdd = true;
        },
    },
    destroyed(){
        this.$store.commit('user/CLEARL_LOTS', []);
    },
}
</script>

<style lang="scss">
.lotsReleaseAdd {
    background-color: #f5f6f7;
    min-height: calc(100vh - 90px);
    // 公共样式
    .title_firm{
        font-size: 14px;
        font-weight: 700;
        padding: 10px 0;
    }


    .getBack_SAVE{
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0px 10px;
        background-color: #fff;
        // border-top: 1px solid #ccc;
        box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
        .l_getBack{
            display: flex;
            align-items: center;
            .l_back_tit{
                font-size: 15px;
                font-weight: bold;
            }
        }
    }
    //=============== 
    .all_box{
        padding: 10px;
    }
    .disposalUniInfor{
        background-color: #fff;
        border-radius: 4px;
        padding: 10px 10px 0 10px;
    }
    .lots_Table{
        background-color: #fff;
        border-radius: 4px;
        padding: 10px;
        margin-top: 10px;
        ::v-deep.el-table th{
            padding: 5px 0;
        }
        ::v-deep.el-table td{
            padding: 5px 0;
        }
        .title_LT{
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 10px;
        }
    }
    .word_content{
        display: flex;
        justify-content: space-between;
        margin-top: 10px;
        .l_box{
            width: 840px;
            margin-right: 10px;
            .l_dispose{
                background-color: #fff;
                border-radius: 4px;
                padding: 10px;
                .firmTable_s{
                    .el-form-item__content{
                        line-height: 0px;
                    }
                }
                
            }
            .l_approve{
                margin-top: 10px;
                background-color: #fff;
                border-radius: 4px;
                padding: 10px;
                .fs_color_tips{
                    font-size: 12px;
                }
            }
        }
        .r_box{
            width: 840px;
            background-color: #fff;
            border-radius: 4px;
            
            .one_editor{
                padding: 10px;  
                border-bottom: 5px solid #f5f6f7;
            }
            .two_editor{
                padding: 10px;  
            }
            .title_rbox{
                margin-bottom: 10px;
            }
        }
    }
    .m_top{
        margin-top: 10px;
    }
}
.ql-container{
      height: 100px;
    }


</style>